package com.aos.eap.activity;

import android.widget.LinearLayout;

import com.aos.eap.R;
import com.aos.eap.adapter.LotInfoListAdapter;
import com.aos.eap.base.BaseDialogActivity;
import com.aos.eap.bean.NameValueBean;
import com.aos.eap.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_AddViewEntity;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class SearchLotActivity extends BaseDialogActivity {


    @BindView(R.id.rvLotInfo)
    RecyclerView rvLotInfo;
    @BindView(R.id.rvBomInfo)
    RecyclerView rvBomInfo;
    @BindView(R.id.llMain)
    LinearLayout llMain;

    private LotInfoListAdapter lotInfoListAdapter;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_search_lot;
    }

    @Override
    protected void initView() {
        rvLotInfo.setLayoutManager(new GridLayoutManager(SearchLotActivity.this, 2));

        rvBomInfo.setLayoutManager(new LinearLayoutManager(SearchLotActivity.this));
        rvBomInfo.setItemAnimator(new DefaultItemAnimator());
        rvBomInfo.addItemDecoration(new DividerItemDecoration(SearchLotActivity.this, 1));

        lotInfoListAdapter = new LotInfoListAdapter(null);
        lotInfoListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        lotInfoListAdapter.isFirstOnly(true);
        rvLotInfo.setAdapter(lotInfoListAdapter);
    }

    @Override
    protected void initData() {
        List<NameValueBean> list = new ArrayList<>();
        NameValueBean nameValueBean1 = new NameValueBean();
        nameValueBean1.setName("Name");
        nameValueBean1.setValue("Value");
        NameValueBean nameValueBean2 = new NameValueBean();
        nameValueBean2.setName("Name");
        nameValueBean2.setValue("Value");
        NameValueBean nameValueBean3 = new NameValueBean();
        nameValueBean3.setName("Name");
        nameValueBean3.setValue("Value");
        list.add(nameValueBean1);
        list.add(nameValueBean2);
        list.add(nameValueBean3);
        list.add(nameValueBean1);
        list.add(nameValueBean3);
        list.add(nameValueBean2);
        list.add(nameValueBean2);
        list.add(nameValueBean1);
        list.add(nameValueBean3);
        list.add(nameValueBean2);
        list.add(nameValueBean3);
        list.add(nameValueBean1);
        list.add(nameValueBean3);
        list.add(nameValueBean1);
        list.add(nameValueBean2);
        list.add(nameValueBean3);
        list.add(nameValueBean2);
        list.add(nameValueBean1);
        lotInfoListAdapter.setNewData(list);
    }


    @Override
    protected FreeUI_AddViewEntity getBaseEntity() {
        freeUI_titleView.setTitle("批次信息查询");
        freeUI_titleView.setLeftListener(view -> showBackDialog(SearchLotActivity.this));
        freeUI_titleView.setRightListener(R.drawable.refresh, v -> {
            if (MyUtils.isFastClick()){
                showToast("您点击的太快了",false);
                return;
            }

        });
        return new FreeUI_AddViewEntity("header", llMain);
    }
}
